package com.crm.app.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.crm.app.domain.AppLoginJour;
import com.crm.app.service.IAppLoginJourService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * APP登录流水Controller
 * 
 * @author ruoyi
 * @date 2024-03-09
 */
@RestController
@RequestMapping("/system/jour")
public class AppLoginJourController extends BaseController
{
    @Autowired
    private IAppLoginJourService appLoginJourService;

    /**
     * 查询APP登录流水列表
     */
    @PreAuthorize("@ss.hasPermi('system:jour:list')")
    @GetMapping("/list")
    public TableDataInfo list(AppLoginJour appLoginJour)
    {
        startPage();
        List<AppLoginJour> list = appLoginJourService.selectAppLoginJourList(appLoginJour);
        return getDataTable(list);
    }

    /**
     * 导出APP登录流水列表
     */
    @PreAuthorize("@ss.hasPermi('system:jour:export')")
    @Log(title = "APP登录流水", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AppLoginJour appLoginJour)
    {
        List<AppLoginJour> list = appLoginJourService.selectAppLoginJourList(appLoginJour);
        ExcelUtil<AppLoginJour> util = new ExcelUtil<AppLoginJour>(AppLoginJour.class);
        util.exportExcel(response, list, "APP登录流水数据");
    }

    /**
     * 获取APP登录流水详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:jour:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(appLoginJourService.selectAppLoginJourById(id));
    }

    /**
     * 新增APP登录流水
     */
    @PreAuthorize("@ss.hasPermi('system:jour:add')")
    @Log(title = "APP登录流水", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AppLoginJour appLoginJour)
    {
        return toAjax(appLoginJourService.insertAppLoginJour(appLoginJour));
    }

    /**
     * 修改APP登录流水
     */
    @PreAuthorize("@ss.hasPermi('system:jour:edit')")
    @Log(title = "APP登录流水", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AppLoginJour appLoginJour)
    {
        return toAjax(appLoginJourService.updateAppLoginJour(appLoginJour));
    }

    /**
     * 删除APP登录流水
     */
    @PreAuthorize("@ss.hasPermi('system:jour:remove')")
    @Log(title = "APP登录流水", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(appLoginJourService.deleteAppLoginJourByIds(ids));
    }
}
